<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--公共头-->
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <!--<link rel="stylesheet" href="./css/font.css">-->
    <link rel="stylesheet" href="./lib/layui/css/layui.css">
    <link rel="stylesheet" href="css/x.css">
    <!--<link rel="stylesheet" href="./css/xadmin.css">-->
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <!--<script type="text/javascript" src="./js/xadmin.js"></script>-->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-body">
    <form class="layui-form layui-form-pane x-form" action="" lay-filter="example">
        <div class="layui-form-item">
            <label class="layui-form-label">username</label>
            <div class="layui-input-block">
                <input type="text" name="username" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">email</label>
            <div class="layui-input-block">
                <input type="text" name="email" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            </div>
        </div>
    </form>
</div>
</body>
<script language="JavaScript">
    let form;
    layui.use('form', function () {
        form = layui.form;
    });

    function formInit(data) {
        form.val('example', {
            "username": data.username,// "name": "value"
            "email": data.email
        });
    }
</script>
</html>